<?php
/**
 * Created by IntelliJ IDEA.
 * User: Allure
 * Date: 2018-11-06
 * Time: 21:31
 */

namespace app\admin\controller;


class Invoice extends ApiCommon
{
    public function index(){
        $postModel = model('Invoice');
        $param = $this->param;
        $keywords = empty($param['keywords'])? $param['keywords']: '';
        $data = $postModel->getDataList($keywords,$param['page'],$param['limit'],$param);
        return resultArray(['data' => $data]);
    }

    public function read()
    {
        $ruleModel = model('Invoice');
        $param = $this->param;
        $data = $ruleModel->getDataById($param['id']);
        if (!$data) {
            return resultArray(['error' => $ruleModel->getError()]);
        }
        return resultArray(['data' => $data]);
    }
    public function update()
    {
        $ruleModel = model('Invoice');
        $param = $this->param;
        $data = $ruleModel->updateDataById($param, $param['id']);
        if (!$data) {
            return resultArray(['error' => $ruleModel->getError()]);
        }
        return resultArray(['data' => '编辑成功']);
    }
}